package com.outdd.vaietool.common.enumerate;

/**
 * @program: Source
 * @description:
 * @author: VAIE
 * @create: 2021-05-19 11:09
 **/
public enum SourceEnum {

    /**
     * 客户基本检索
     **/
    QI_DIAN("QIDIAN",
            "01",
            "起点中文网",
            ".volume .cf li a",
            ".content-wrap",
            ".read-content",false,0),
    QU_BI_GR("QUBIGR",
            "02",
            "趣笔阁",
            "#list dl dd a",
            ".bookname h1",
            "#content",true,9);

    /**
     * 描述
     **/
    private String desc;
    /**
     * 对应的代码
     **/
    private String code;
    /**
     * 中文描述
     **/
    private String zhDesc;
    /**
     * 目录规则
     **/
    private String directoryRule;
    /**
     * 标题描述
     **/
    private String titleRule;
    /**
     * 内容描述
     **/
    private String contentsRule;

    /**
     * 内容描述
     **/
    private boolean isAddHost;

    /**
     * 内容描述
     **/
    private Integer skipNum;

    /**
     * 私有构造,防止被外部调用
     *
     * @param desc
     */
    SourceEnum(String desc,
               String code,
               String zhDesc,
               String directoryRule,
               String titleRule,
               String contentsRule,
               boolean isAddHost,
               Integer skipNum) {
        this.desc = desc;
        this.code = code;
        this.zhDesc = zhDesc;
        this.directoryRule = directoryRule;
        this.titleRule = titleRule;
        this.contentsRule = contentsRule;
        this.isAddHost = isAddHost;
        this.skipNum = skipNum;
    }


    /**
     * 获取code值
     *
     * @param code
     * @return
     */
    public static String getCode(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getCode();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static String getDesc(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getDesc();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static String getZhDesc(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getZhDesc();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static String getDirectoryRule(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getDirectoryRule();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static String getTitleRule(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getTitleRule();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static String getContentsRule(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getContentsRule();
            }
        }
        return null;
    }

    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static boolean getIsAddHost(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getIsAddHost();
            }
        }
        return false;
    }
    /**
     * 获取描述
     *
     * @param code
     * @return
     */
    public static Integer getSkipNum(String code) {
        SourceEnum[] enums = values();
        for (SourceEnum objEnum : enums) {
            if (objEnum.getCode().equals(code)) {
                return objEnum.getSkipNum();
            }
        }
        return 0;
    }

    /**
     * 获取描述
     * @param desc
     * @return
     */
    public static SourceEnum getEnum(String desc) {
        SourceEnum[] businessModeEnums = values();
        for (SourceEnum patternTypeEnum : businessModeEnums) {
            if (patternTypeEnum.getDesc().equals(desc)) {
                return patternTypeEnum;
            }
        }
        return null;
    }


    public String getDesc() {
        return desc;
    }

    public String getCode() {
        return code;
    }

    public String getZhDesc() {
        return zhDesc;
    }

    public String getDirectoryRule() {
        return directoryRule;
    }

    public String getTitleRule() {
        return titleRule;
    }

    public String getContentsRule() {
        return contentsRule;
    }

    public boolean getIsAddHost() {
        return isAddHost;
    }
    public Integer getSkipNum() {
        return skipNum;
    }
}
